<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath()+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=path%>">
    <script type="text/javascript" src="<%=path %>static/Information/js/jquery.min.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="x-dns-prefetch-control" content="on">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
    <title>卡王贷-让贷款借钱更简单，最快1天放款</title>
    <meta name="apple-mobile-web-app-title" content="卡王贷">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="format-detection" content="telephone=no,email=no,address=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="HandheldFriendly" content="true">
    <meta name="MobileOptimized" content="320">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <meta name="msapplication-tap-highlight" content="no">
    <link href="static/Information/css/style.css" rel="stylesheet" type="text/css">
    <script src="static/Information/js/ec_valid.js"></script>
    <script src="static/Information/js/ec_gsc.js"></script>
    <script type="text/javascript" src="static/Information/js/jquery.min.js"></script>
    <script type="text/javascript" src="static/Information/js/ec_ac_jh.js"></script>
    <script type="text/javascript" src="static/Information/js//finutil_a.js"></script>
    <script type="text/javascript" src="static/Information/js/crypto-js.js"></script>
    <script type="text/javascript" src="static/Information/js/mobiscroll.js"></script>
    <script type="text/javascript" src="static/Information/js/alert_2.js"></script>
    <!-- <script type="text/javascript" src="js/alert.js"></script> -->
    <script type="text/javascript" src="static/Information/js/mobile-select.js"></script>
    <script type="text/javascript" src="static/Information/js/iscroll.js"></script>
    <script type="text/javascript" src="static/Information/js/areaData_v2.js"></script>
    <script type="text/javascript" src="static/Information/js/iosSelect.js"></script>
</head>
<body style="background-color: rgb(220, 40, 51);">
<div id="app">
    <div class="contains">
        <div class="signup" style="background-image: url(static/Information/images/bg.png);">
            <div class="signup__body">
                <div>
                    <div class="signup__form">
                        <div class="form--item">
                            <input type="tel" maxlength="11" class="signup__form--mobile inp" placeholder="请输入您的手机号码" autocomplete="off" value=""  id="mobile">
                        </div>
                        <div class="form--item">
                            <div id="captchaContainer" class="captchaContainer"></div>
                        </div>
                        <div class="form--item">
                            <div class="btn-group">
                                <input type="tel" placeholder="请输入收到的验证码" class="signup__form--smscode inp" value="" id="textcode">
                                <div>
                                    <div>
                                        <button type="button" class="btn signup__form--get-code" style="overflow: hidden; padding: 0px 1%;"onClick="sub()" id="getcode">获取验证码</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form--item" style="margin: 15px 0px; color: rgb(255, 255, 255); font-size: 12px;"><input type="checkbox" checked style="padding: 5px;width: auto;margin:0 10px 0 0;">申请有礼：送100万赔付意外险，平安出行
                        </div>
                        <div class="form--item" style="margin: 15px 0px; color: rgb(255, 255, 255); font-size: 12px;">点击“立即领钱”代表您已同意<a href="information/userNotes" style="color: rgb(254, 253, 56);">《用户服务协议》</a>
                        </div>
                        <button type="submit" class="btn signup__form--submit" id="submitForm">立即领钱</button>
                        <div class="spin--wrapper"></div>
                    </div>
                    <img src="static/Information/images/flow.png" class="signup__slogan">
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var gsc = new EC_GSC('FIN');
    function sub() {
        if (!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test($("#mobile").val())) || $("#mobile").val().length !== 11) {
            $("#mobile").focus();
            alert("您的电话输入有误，请重新填写！");
            return false;
        }
        //$(".dk_popupContainer").fadeIn();
        var oCodeBtn = $("#getcode");
        oCodeBtn.css("backgroundColor", "#8a8888");
        oCodeBtn.attr("disabled", "disabled");
        //      oCodeBtn.attr("value", "1分钟后再试");
        var i = 100;

        var timer = setInterval(function () {
            if (i === 0) {
                clearInterval(timer);
                oCodeBtn.css("backgroundColor", "#27b3dc");
                oCodeBtn.removeAttr("disabled");
                //oCodeBtn.attr("value", "获取短信验证码");
                oCodeBtn.text("获取短信验证码");
                oCodeBtn.te
                return;
            }
            //oCodeBtn.attr("value", "请" + i + "秒后再试");
            oCodeBtn.text("请" + i + "秒后再试");
            i--
        }, 1000);

        var mobile = $('#mobile').val();
        gsc.getCode(mobile)
    }
    $("#submitForm").click(function () {
        if (!isPhoneNumber($("#mobile").val())) {
            $("#mobile").focus();
            alert("您的电话输入有误，请重新填写！");
            return false;
        }
        var mobile = $("#mobile").val();
        var  code = $("#textcode").val();
        //console.log(mobile+code+"");
        gsc.verifyCode(mobile, code, smsCodeCallback);
    });
    function smsCodeCallback(ret) {
        console.log("Sms verify result = " + ret);
        if (ret === 0) {
            submitMobile();
        } else {
            alert("验证码输入错误");
        }
    }

    function submitMobile(){
        var mobile = $("#mobile").val();
        var cid = getQueryString("cid");
        $.ajax({
            url:"information/addMobile",
            type:"POST",
            data:{"phone":mobile,
                "cid":cid},
            success: function(data){
                if(data.code == 200 ){
                    //goto();
                    window.location.href = "<%=path%>information/signUp2?phone="+mobile;
                    console.log("提交成功");
                }else{
                    alert("请求失败，请重新进行提交");
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                console.log(XMLHttpRequest);
                alert("请求失败，请重新进行提交");
            }
        });
    }
</script>
</body>
</html>
